Skip to content

Add initial support for powerpc64le initialization. #267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

BODAPATIMAHESH
Copy link

@BODAPATIMAHESH BODAPATIMAHESH commented Nov 21, 2024

Added header definitions for PPC64LE.

Implemented support to construct and report processor topology information including processor, core, cluster, package, PVR, and cache levels (L1i, L1d, L2, and L3).

Test:

Built and executed cpu_info on a PPC64LE Linux machine. Confirmed that it accurately reports logical processors, cores, clusters, packages, and cache information.

Ran unit tests and verified that there were no regressions.

    * Adds header definitions for PPC64le
    * Adds support to construct the processor, core, cluster, package
      and cache(L1i,L1d,L2 and L3) information reported by the system.

    Test: Build and ran cpu_info on PPC64le linux machine. confirmed
          that it properly reports the logical processors, cores, clusters,
          packages and cache information.
int b = (uint32_t) getauxval(AT_HWCAP2);
#endif //CPUINFO_MOCK //

#if (b & CPUINFO_POWERPC_LINUX_FEATURE_ARCH_3_1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please explain how that is supposed to work?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@malfet when AT_hwcap2 supports the feature arch_3_1(Power10) then cpuinfo_initialization should set these features mma,vsx
_```
#if (b & CPUINFO_POWERPC_LINUX_FEATURE_ARCH_3_1)
EXPECT_EQ(0, cpuinfo_has_powerpc_htm());
EXPECT_EQ(1, cpuinfo_has_powerpc_mma());
EXPECT_EQ(1, cpuinfo_has_powerpc_vsx());

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#if is a preprocessor directive, isn't it?
And b is not defined when preprocessor is invoked, so all those conditions will simply never be compiled, aren't they?

So, I would like to see some sort of a thorough test plan for this PR before accepting it

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right. All those conditions will not be compiled, and the test case will not throw any error.
I have used if-elseif conditions to make it work, and below is the debugging screenshot that is going through the if() condition.
Since CPUINFO_MOCK is not implemented for PPC64le, I have removed the redundant code. Please go through the latest code changes and let me know your review comments.
Screenshot 2025-01-30 at 6 14 50 PM

Comment on lines 304 to 306
cpuinfo_log_info(
"failed to parse online status for processor %" PRIu32 " from %s", processor, processor_online_filename);
return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent seems wrong here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I will fix all the indent errors

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@malfet I have fixed indentation. could you review it

@BODAPATIMAHESH
Copy link
Author

@malfet could you review the patch again

@BODAPATIMAHESH
Copy link
Author

Hi @malfet , Did you get a chance to review this patch?

@BODAPATIMAHESH
Copy link
Author

BODAPATIMAHESH commented Jan 19, 2025

@malfet I am waiting for your review.
Thanks.

@BODAPATIMAHESH
Copy link
Author

@fbarchard @malfet can you review this.

Copy link
Contributor

@malfet malfet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still confused about use of #if (b & FOOBAR) conditions in the test

int b = (uint32_t)getauxval(AT_HWCAP2);
#endif // CPUINFO_MOCK //

#if (b & CPUINFO_POWERPC_LINUX_FEATURE_ARCH_3_1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please explain to me, when something like that would be evaluated to true?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes , you are right . I have updated the code.

@BODAPATIMAHESH
Copy link
Author

I have updated the code. Please review it @malfet

@BODAPATIMAHESH
Copy link
Author

@malfet can you review the latest code.

@seemethere seemethere requested a review from Copilot April 30, 2025 16:17
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds initial support for powerpc64le initialization including new header definitions, architectural decoding logic, and test coverage for POWER-specific features.

  • Adds new cases to uarch-to-string conversion to support POWER7, POWER8, POWER9, and POWER10.
  • Introduces PPC64-specific processing flows in CPU parsing, cache handling, and initialization.
  • Updates configuration and test infrastructure to integrate PPC64 support.

Reviewed Changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tools/cpu-info.c New POWER architecture cases added in the uarch_to_string function.
test/name/power-features.cc Added tests for POWER-specific features based on auxiliary vector flags.
test/init.cc Conditionals to disable cache consistency tests for PPC64 are added.
src/powerpc/uarch.c, linux/ppc64-isa.c, linux/ppc64-hw.c New implementations for decoding vendor, ISA, and hardware capabilities on PPC64.
src/powerpc/linux/cpuinfo.c CPU parsing updated to support POWER processor architectures with proper logging.
src/powerpc/cache.c New implementation for decoding cache information for PPC processors.
src/linux/processors.c & src/linux/api.h Added functions to get processor online status on Linux.
src/init.c, internal-api.h, src/api.c Updated PPC64 branches added to initialization and global data.
include/cpuinfo.h Added PPC-specific fields and inline feature functions.
configure.py Configures PPC64-specific source files and tests for build targets.
Files not reviewed (1)
  • CMakeLists.txt: Language not supported

#endif
/** Clock rate (non-Turbo) of the core, in Hz */
uint64_t frequency;

bool disabled;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please mention in PR description that it adds a new property (though I though there were already one) And where is it initialized for other architectures?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @malfet for reviewing it. Updated the commit description and the Processor Version Register (PVR) on PowerPC (ppc64) architectures uniquely identifies the processor version and revision. Other CPU architectures provide similar capabilities, though they go by different names and mechanisms , for example
ARM / AArch64 : MIDR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants